package com.youshang520i.springcommonmiddleware.mq.rabbitmq.service.impl;

import com.youshang520i.springcommonmiddleware.mq.rabbitmq.po.Mail;
import com.youshang520i.springcommonmiddleware.mq.rabbitmq.service.Producer;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 生产者-消费者模型，向队列生产消息
 */
@Transactional
@Service("producer")
public class ProducerImpl implements Producer {
    @Autowired
    RabbitTemplate rabbitTemplate;


    @Override
    public void sendMail(String queue, Mail mail) {
//        rabbitTemplate.setQueue(queue);
        rabbitTemplate.convertAndSend(queue,mail);
    }

}
